package com.mock.action.product;

import com.mock.dao.ProductDao;
import com.mock.dao.ProductTypeDao;
import com.mock.dao.impl.ProductDaoImpl;
import com.mock.dao.impl.ProductTypeDaoImpl;
import com.mock.model.Product;
import com.mock.model.ProductType;
import com.opensymphony.xwork2.ActionSupport;

public class AddProductAction extends ActionSupport{

	private Product product;
	private Long productTypeId;
	
	
	private ProductDao productDao = new ProductDaoImpl();
	private ProductTypeDao productTypeDao = new ProductTypeDaoImpl();
	
	public String execute() {
		
		ProductType productType = productTypeDao.getById(ProductType.class, productTypeId);
		product.setProductType(productType);
		productDao.add(product);
		return SUCCESS;
	}

	public Product getProduct() {
		return product;
	}

	public void setProduct(Product product) {
		this.product = product;
	}

	public Long getProductTypeId() {
		return productTypeId;
	}

	public void setProductTypeId(Long productTypeId) {
		this.productTypeId = productTypeId;
	}
	
	
 	
}
